#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point()
    : _ix(0)
    , _iy(0)
    {
        cout << "Point()" << endl;
    }

    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "拷贝构造" << endl;
    }

    Point & operator=(const Point & rhs){
        /* cout << "赋值运算符函数" << endl; */
        _ix = rhs._ix;
        _iy = rhs._iy;
        return *this;
    }

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }
private:
    int _ix;
    int _iy;
};

void test0(){
    Point * p1 = new Point(3,4);
    p1->print();
    (*p1).print();
    delete p1;

    //结尾的()确保进行了初始化
    //初始化为相应类型的默认值
    int * p = new int();
    cout << *p << endl;
    delete p;

    //Point类型的默认值就是无参构造初始化的Point对象
    Point * p2 = new Point();
    p2->print();
    delete p2;

    Point pt;
    pt.print();
}

void test1(){
    Point pt(5,6);
    Point pt2(3,9);
    Point pt3(4,8);
    Point arr[3] = {pt,pt2,pt3};
    cout << &pt << endl;
    cout << arr << endl;

    Point arr2[2] = {Point(3,6),Point(8,9)};
    arr2[0].print();
    (arr2 + 1)->print();


    Point arr3[2] = {{2,6},{6,7}};
}

int main(void){
    test1();
    return 0;
}
